//! # 高级构建器核心接口定义
//! 
//! 本模块定义了RustCloud框架高级构建器的核心接口，包括插件、验证器和环境适配器接口。

use crate::config::RustCloudConfig;
use crate::framework::RustCloudFramework;
use crate::advanced_builder::AdvancedRustCloudBuilder;
use rustcloud_core::{ServiceResult, ServiceError};
use std::collections::HashMap;

/// 构建器插件trait
#[async_trait::async_trait]
pub trait BuilderPlugin: Send + Sync {
    /// 插件名称
    fn name(&self) -> &str;
    
    /// 插件描述
    fn description(&self) -> &str {
        ""
    }
    
    /// 插件版本
    fn version(&self) -> &str {
        "1.0.0"
    }
    
    /// 应用插件配置
    async fn apply(&self, builder: &mut AdvancedRustCloudBuilder) -> ServiceResult<()>;
    
    /// 插件依赖
    fn dependencies(&self) -> Vec<String> {
        Vec::new()
    }
    
    /// 插件优先级
    fn priority(&self) -> i32 {
        0
    }
}

/// 配置验证器trait
#[async_trait::async_trait]
pub trait ConfigValidator: Send + Sync {
    /// 验证配置
    async fn validate(&self, config: &RustCloudConfig) -> ServiceResult<()>;
    
    /// 验证器名称
    fn name(&self) -> &str;
}

/// 环境适配器trait
#[async_trait::async_trait]
pub trait EnvironmentAdapter: Send + Sync {
    /// 适配配置到特定环境
    async fn adapt(&self, config: &mut RustCloudConfig) -> ServiceResult<()>;
    
    /// 环境名称
    fn environment(&self) -> &str;
}

/// 构建钩子trait
#[async_trait::async_trait]
pub trait BuildHook: Send + Sync {
    /// 构建前钩子
    async fn before_build(&self, builder: &AdvancedRustCloudBuilder) -> ServiceResult<()> {
        Ok(())
    }
    
    /// 构建后钩子
    async fn after_build(&self, framework: &RustCloudFramework) -> ServiceResult<()> {
        Ok(())
    }
}